//
//  ALBaseTableCell.m
//  Amily
//
//  Created by 张鹏 on 15/8/14.
//  Copyright (c) 2015年 Amily. All rights reserved.
//

#import "ALBaseTableCell.h"

@implementation ALBaseTableCell


- (void)prepareForReuse
{
    [super prepareForReuse];
}

+ (instancetype)dequeueReusableTable:(UITableView *)tableView
{
    NSString *cellIdentify = NSStringFromClass([self class]);
    id cell =  [tableView dequeueReusableCellWithIdentifier:cellIdentify];
   
    if (!cell) {
        cell = [self loadCellFromXib];
    }
    
    return cell;
}

+ (CGFloat)heightForRowCell:(UITableView *)tableView
{
    if ([UIDevice iOS8Later]) {
        return UITableViewAutomaticDimension;
    }else{

        ALBaseTableCell *cell = [self dequeueReusableTable:tableView];
        [cell setNeedsUpdateConstraints];
        [cell updateConstraintsIfNeeded];
        [cell setNeedsLayout];
        [cell layoutIfNeeded];
        return [cell.contentView
            systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
    }
}

+ (instancetype)loadCellFromXib
{
    return [LoadXibTool loadViewFromXibName:NSStringFromClass([self class])];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    // Configure the view for the selected state
}

@end
